package com.kotodama.infrastructure.tenant.context;

/**
 * 基于 ThreadLocal 保存当前请求租户信息，确保在当前线程及其子线程中可用。
 */
public class TenantContext {

    private static final ThreadLocal<String> TENANT_HOLDER = new InheritableThreadLocal<>();

    public static void setTenantId(String tenantId) {
        TENANT_HOLDER.set(tenantId);
    }

    public static String getTenantId() {
        return TENANT_HOLDER.get();
    }

    public static void clear() {
        TENANT_HOLDER.remove();
    }

    private TenantContext() {}
}
